package BeenChina.PM.Action; 
import java.util.ArrayList;
import java.util.List;
 
import BeenChina.PM.Model.ModelCaseNumber;  
import BeenChina.PM.Service.ServiceFactory;
import BeenChina.PM.Util.JqGridBaseAction;
import BeenChina.PM.Util.StringUtil;

public class CaseNumberQueryAction extends JqGridBaseAction<ModelCaseNumber> {
	private static final long serialVersionUID = 1L;
	private List<ModelCaseNumber> caseNumberList =new ArrayList<ModelCaseNumber>();	
	private String	dateFrom,dateTo,dateFiled;
	
	public void setDateFrom(String dateFrom){
		this.dateFrom = dateFrom;
	}
	
	public void setDateTo(String dateTo){
		this.dateTo = dateTo;
	}
	
	public String getDateField(){ 	
		return this.dateFiled;	
	}
	public void setDateField(String dateField){ 	
		this.dateFiled  = dateField;	
	}
	
	@Override
	public int getResultSize() {
		return this.caseNumberList.size();  
	}

	@Override
	public List<ModelCaseNumber> listResults(int from, int length) throws Exception { 
		try{
			 if (StringUtil.isDate(dateFrom) &&   StringUtil.isDate(dateTo)  ){
				 caseNumberList = ServiceFactory.getInstance().getCaseInfoService().selectCaseNumber( this.dateFrom, this.dateTo,this.dateFiled);
			 }
			return caseNumberList;
		}
		catch(Exception exp){
			 throw exp;
		}		 		  
	}	
	
	 @Override
	public String execute() {
		dateFiled="receiptdate";
		//setCaseList(this.caseList);
		return "load";
	}
}